from apps.interface.client.baseViews import *

class ClientViewSet(BaseClientViewSet):

    needCheckList = ['chatMessage','orderList', 'rentPublic', 'housePublic', 'itemDetail','businessCenter', 'lesseeDetail', 'lesseeList', 'lesseeCheckin', 'addrList', 'paywayList', 'wallet', 'myVipCart', 'myCoupon', 'qrCode','shopCart','shopReceing']
    def get_queryset(self):
        params = getRequestParams(self.request)
        _list = ClientDao().findAll()
        if self.request.user.role.key == 'superAdmin' or self.request.user.role.key == 'admin':
            _list = _list
        return _list

    @action(methods=['post'], detail=False, authentication_classes=[], permission_classes=[])
    def findClientInfo(self, request):
        params = getRequestParams(self.request)
        clientname = params.get('clientname')
        if isEmptyStr(clientname):
            return Response(response_message('clientname字段必填'))
        _objs = ClientDao().findAll().filter(clientname=clientname)
        if not _objs.exists():
            return Response(response_message('记录不存在'))
        model = ClientModelSerializer(_objs.first()).data
        model['needCheckList'] = self.needCheckList
        return Response(response_success(model))